﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace spel 
{
    //jerry ska "springa ifrån tom"
    class jerry
    {


        public Vector2 Position;
        private Texture2D texture;
        private SpriteBatch spriteBatch;
        private Game1 game;


        public Rectangle GetRectangle() 
        {
            Rectangle r = new Rectangle( (int) Position.X, (int) Position.Y, texture.Width, texture.Height);
            return r;
        }

        public void Update(GameTime gameTime)
        {
            
            KeyboardState ks = Keyboard.GetState();
            if (ks.IsKeyDown(Keys.A) || ks.IsKeyDown(Keys.Left)) 
            {
                Position.X -= 3;
            }
            if (ks.IsKeyDown(Keys.D) || ks.IsKeyDown(Keys.Right))
            {
                Position.X += 3;
            }
          

            if (ks.IsKeyDown(Keys.W) || ks.IsKeyDown(Keys.Up))
            {
                Position.Y -= 3;
            }
            if (ks.IsKeyDown(Keys.S) || ks.IsKeyDown(Keys.Down))
            {
                Position.Y += 3;
            }
            
        }

        

        public void Draw(GameTime gameTime)
        {
            spriteBatch.Begin();
            spriteBatch.Draw(texture, Position, Color.White);
            spriteBatch.End();
        }

        public jerry(Game1 game, Texture2D texture, SpriteBatch spriteBatch)
        {
            Vector2 startpos = new Vector2(0, 0);
            this.spriteBatch = spriteBatch;
            this.texture = texture;
            this.game = game;
            
        }
    }
}
